/**   
 * @Title: Result.java
 * @Package com.hxd.love.api
 * @Description: TODO(用一句话描述该文件做什么)
 * @author 谢会超   
 * @date 2015-8-12 下午1:26:06
 * @version V1.0   
 */

package net.bblot.lottery.api.result;

import org.json.JSONObject;



/**
 * @ClassName: Result
 * @Description: TODO(针对执行结果的封装)
 * @author 谢会超
 * @date 2015-8-12 下午1:26:06
 * 
 */

public class ExcuterResult  {

	private final static String TAG = "ExcuterResult";
	private int sc;
	private int errcode;
	private String errmsg;
	private String result;
	private long date;

	public static final int ERRCODE_10001 = 10001;
	public static final int ERRCODE_10002 = 10002;

	
	public static ExcuterResult parseErrorFromHttpResultCode(HttpResult hr) {
		ExcuterResult er = new ExcuterResult();
		String result = hr.getResult();
		try {
			result = hr.getResult();
			er.setSc(hr.getSc());
			er.setResult(hr.getResult());
			er.setDate(hr.getDate());
			JSONObject jo = new JSONObject(result);
			er.setErrcode(jo.optInt("code", 0));
			er.setErrmsg(jo.optString("code_str", ""));		
		} catch (Exception e) {
//			e.printStackTrace();
		}
		return er;
	}

	/**
	 * @return sc
	 */

	public int getSc() {
		return sc;
	}

	/**
	 * @param sc
	 *            要设置的 sc
	 */

	public void setSc(int sc) {
		this.sc = sc;
	}

	/**
	 * @return errcode
	 */

	public int getErrcode() {
		return errcode;
	}

	/**
	 * @param errcode
	 *            要设置的 errcode
	 */

	public void setErrcode(int errcode) {
		this.errcode = errcode;
	}

	/**
	 * @return errmsg
	 */

	public String getErrmsg() {
		return errmsg;
	}

	/**
	 * @param errmsg
	 *            要设置的 errmsg
	 */

	public void setErrmsg(String errmsg) {
		this.errmsg = errmsg;
	}

	/**
	 * @return result
	 */

	public String getResult() {
		return result;
	}

	/**
	 * @param result
	 *            要设置的 result
	 */

	public void setResult(String result) {
		this.result = result;
	}

	/**
	 * @return date
	 */

	public long getDate() {
		return date;
	}

	/**
	 * @param date
	 *            要设置的 date
	 */

	public void setDate(long date) {
		this.date = date;
	}
}
